import http from '@/utils/http'

interface BasicParams {
    dtoName: string // 参考后端接口文档
    queryId: string // 参考confluence上的页面需求SQL标识
    version: string // 参考confluence上的页面需求SQL版本号
    menuName: string // 菜单的标识，与菜单管理配置保持一致
    usage: string // 接口后缀，标识用途
}
/*
  eg./ims-tworkgz-service/viewCstHistory/getCstHistory
*/

/** 获取 ExceptionCode信息 */
export function getExceptionCode({ shopId, reasonCodeType }: { shopId: string, reasonCodeType: string }): Promise<any> {
  const data = {
    dtoName: 'ChangePanelGradeExceptionCodeDTO',
    queryId: 'GetReasonCodeList',
    version: '80001',
    reasonCodeType: 'SCRAP',
    shopId
  }
  return http.request({
    url: '/ims-tworkgz-service/changePanelGrade/getExceptionCode',
    method: 'POST',
    data
  })
}

/** 获取 Panel Grade 信息 */
export function getPanelGrade({
  shopId
}: { shopId: string }): Promise<any> {
  const data = {
    dtoName: 'ChangePanelGradeIdDTO',
    gradeType: 'Product',
    queryId: 'GetGradeList',
    version: '80003',
    shopId
  }
  return http.request({
    url: '/ims-tworkgz-service/changePanelGrade/getGrade',
    method: 'POST',
    data
  })
}

/** 获取 Panel Grade List信息 */
export function getPanelGradeList(data: BasicParams): Promise<any> {
  return http.request({
    url: '/ims-tworkgz-service/changePanelGrade/getPanelGradeList',
    method: 'POST',
    data
  })
}

/** 获取 ReasonCode信息 */
export function getReasonCode({ reasonCodeType, shopId }: { reasonCodeType: string, shopId: string }): Promise<any> {
  const data = {
    dtoName: 'ChangeGlassGradeReasonCodeDTO',
    queryId: 'GetReasonCodeList',
    version: '80017',
    reasonCodeType,
    shopId
  }
  return http.request({
    url: '/ims-tworkgz-service/changePanelGrade/getReasonCode',
    method: 'POST',
    data
  })
}

/** 获取 ReasonCodeType信息 */
export function getReasonCodeType(): Promise<any> {
  const data = {
    dtoName: 'ChangePanelGradeReasonCodeTypeDTO',
    queryId: 'GetReasonCodeTypeList',
    version: '80001'
  }
  return http.request({
    url: '/ims-tworkgz-service/changePanelGrade/getReasonCodeType',
    method: 'POST',
    data
  })
}

/** 获取 Exception Code 子信息 */
export function getSubExceptionCode({ exceptionCode, reasonCodeType, shopId }: { exceptionCode: string, reasonCodeType: string, shopId: string }): Promise<any> {
  const data = {
    dtoName: 'ChangePanelGradeSubExceptionCodeDTO',
    exceptionCode,
    queryId: 'GetReasonCodeList',
    reasonCodeType,
    shopId,
    version: '80006'
  }
  return http.request({
    url: '/ims-tworkgz-service/changePanelGrade/getSubExceptionCode',
    method: 'POST',
    data
  })
}
